﻿using Microsoft.EntityFrameworkCore.Diagnostics;
using System.Data.Common;

namespace AspNetCoreMvcPrj
{
    public class DmStringTypeInterceptor : DbCommandInterceptor
    {
        public override InterceptionResult<DbDataReader> ReaderExecuting(
            DbCommand command, CommandEventData eventData, InterceptionResult<DbDataReader> result)
        {
            command.CommandText = command.CommandText
                .Replace("CAST(@p0 AS AnsiString)", "CAST(@p0 AS VARCHAR)");
            return result;
        }
    }

}
